/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.untar;

import cn.ac.iie.di.global.GlobalParas;
import cn.ac.iie.di.tools.FileTools;
import cn.ac.iie.di.tools.TarTools;
import cn.ac.iie.di.tools.UnzipTools;
import java.io.File;
import java.util.List;

/**
 *
 * @author lenovo-pc
 */
public class TarTask implements Runnable {

    static org.apache.log4j.Logger logger = null;
    private final String filename;

    static {
        logger = org.apache.log4j.Logger.getLogger(TarTask.class.getName());
    }

    public TarTask(String filename) {
        this.filename = filename;
    }

    @Override
    public void run() {
        TarTools uz = new TarTools();
        FileTools ft = new FileTools();
        try {

            //解压文件
            //判断有.sig再解压
            Boolean flag = uz.inflat(GlobalParas.ORI_GWX, filename, GlobalParas.TMP_GWX);
            if (!flag) {
                logger.debug("+++++++++" + filename + " unzip error");
                return;
            }
            //移动文件
            File fileok = new File(GlobalParas.ORI_GWX + File.separator + filename + ".ok");
            if (!fileok.exists()) {
                ft.moveGzFileToNewPath(GlobalParas.ORI_GWX + File.separator + filename, GlobalParas.DES_GWX);
            }
        } catch (Exception e) {
            logger.error("=============ungzipTask is error:" + e, e);
        }

    }

}
